#include "CBigTitleDialog.h"
#include "CLabel.h"

CBigTitleDialog::CBigTitleDialog(QWidget *parent) : CDialog(parent) {
    init();
}

CBigTitleDialog::~CBigTitleDialog() {
}

void CBigTitleDialog::init() {
    m_titleLabel = new CLabel();
    m_titleLabel->setObjectName("dialog-title-label");
    m_titleLabel->setAlignment(Qt::AlignCenter);

    m_layout->insertWidget(1, m_titleLabel);

    setTitleVisible(false);
}

void CBigTitleDialog::setNative(bool value) {
    CDialog::setNative(value);
    m_titleLabel->setVisible(value);
}

void CBigTitleDialog::windowTitleChangeEvent(QEvent *event) {
    QString title = windowTitle();

    QFontMetrics font(m_titleLabel->font());
    m_titleLabel->setText(font.elidedText(title, Qt::ElideRight, m_titleLabel->width()));

    CDialog::windowTitleChangeEvent(event);
}
